<?php
//使用fsockopen函数模拟文件上传，
//可以使用firebug查看上传文件具体post的数据
$host='localhost';
$port=80;
$path='/framework/Upload/example/socket/handle.php';
// the file you want to upload
$file_array[0] = "./src/src.jpg"; // the file
$content_type = "image/jpeg"; // the file mime type
//$content_type = "text/plain";
//echo "file_array[0]:$file_array[0]<br><br>";
srand((double)microtime()*1000000);
$boundary = "---------------------------".substr(md5(rand(0,32000)),0,10);
$data = "--$boundary";
for($i=0;$i<count($file_array);$i++){
   $content_file = file_get_contents($file_array[$i]);
   $data.="
Content-Disposition: form-data; name=\"logo\"; filename=\"".basename($file_array[$i])."\"
Content-Type: $content_type

$content_file
--$boundary";
}
$data.="--\r\n";
$msg =
"POST $path HTTP/1.0
Host: $host
Content-Type: multipart/form-data; boundary=$boundary
Content-Length: ".strlen($data)."\r\n\r\n";
$result="";
// open the connection
$f = fsockopen($host, $port);
fputs($f,$msg.$data);
// get the response
while (!feof($f)) $result .= fread($f,32000);
fclose($f);
var_dump($result);
?>